﻿using System;
using Chip8.Core.Bus;

namespace Chip8.Core.Processor.Operations
{
	internal class SEv : Operation
	{
		public SEv(int registerIndex, byte value)
		{
			RegisterIndex = registerIndex;
			Value = value;
		}

		public int RegisterIndex { get; set; }

		public short Value { get; set; }

		public override void Execute(ICPU cpu)
		{
			if (cpu.V[RegisterIndex] == Value)
			{
				cpu.PC += 2*Chip8.OpcodeSize;
			}
		}
	}

	internal class SEr : Operation
	{
		public SEr(int registerIndex1, int registerIndex2)
		{
			RegisterIndex1 = registerIndex1;
			RegisterIndex2 = registerIndex2;
		}

		public int RegisterIndex1 { get; set; }

		public int RegisterIndex2 { get; set; }

		public override void Execute(ICPU cpu)
		{
			if (cpu.V[RegisterIndex1] == cpu.V[RegisterIndex2])
			{
				cpu.PC += 2 * Chip8.OpcodeSize;
			}
		}
	}
}
